<template>
	<view class="container">
		<view class="list border-b" @click="SheetInfo(item)" v-for="item in List">
			<view class="icon"><image :src="'/static/'+GetIcon(item.Method)+'.png'"/></view><view class="name" :class="item.Type==1?'red':'blue'">{{item.Name}}</view><view :class="''+GetDot(item.Method)" class="dot"></view>
		</view>
		<view class="btn" v-if="RoleID==7">
			<button class="publishs" v-if="Info.State<3" @click="CancelAudit()">取消审核</button>
			<button class="deletes"  @click="DeleteCase()">删除</button>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				ID:0,
				RoleID:0,
				Info:{},
				List:[]
			};
		},
		onPullDownRefresh() {
			this.Find_CaseInfo();
		},
		onLoad(options) {
			this.ID=options.ID;
			this.RoleID=uni.getStorageSync("RoleID");
			this.Find_CaseInfo();
		},
		methods:{
			Find_CaseInfo(){
				var data = {};
				data.Act="Find_CaseInfo";
				data.ID=this.ID;
				this.Util.Loading("加载中...");
				this.Util.Post2(data, json=>{
					uni.hideLoading();
					uni.stopPullDownRefresh();
					uni.hideNavigationBarLoading();
					this.Info = json.Data.Info;
					this.Find_SheetMenu();
				});
			},
			Find_SheetMenu(){
				var data={};
				data.ID=this.ID;
				data.Act="Find_SheetMenu";
				this.Util.Post2(data, json=>{
					this.List=json.Data.List;
					this.Util.HideLoading();
					uni.stopPullDownRefresh();
				});
			},
			
			GetIcon(Method){
				var icon="";
				if(this.Info[Method+"_Back"]!=""){
					icon="error";
				}else{
					if(this.Info[Method]!=""){
						icon='success';
					} 
				}
				return icon;
			},
			GetDot(Method){
				if(this.Info[Method+"_AuditRoleID"]==this.RoleID || (Method=="T33" && this.Info["T33_AuditRoleID"]==0 && this.RoleID==7 && this.Info.State==2)){
					return "";
				}else{
					return "hidden";
				}
			},
			SheetInfo(item){
				if(item.Type==1){
					uni.navigateTo({
						url:'/pages/case2/UploadImg?ID='+this.ID+'&SubName='+item.SubName + '&Method=' +item.Method
					})
				}else{
					uni.navigateTo({
						url:'/pages/case2/'+item.Method+'?ID='+this.ID+'&SubName='+item.SubName
					})
				}
			},
			CancelAudit(){
				this.Util.Confirm("是否确定取消审核？",res=>{
					var data = {};
					data.Act="Cancel_Audit";
					data.ID=this.ID;
					this.Util.Loading("请稍候...");
					this.Util.Post2(data, json=>{
						this.Util.HideLoading();
						if(json.State){
							this.Util.Toast(json.Msg, obj=>{
								this.Find_CaseInfo();
							});
						}else{
							this.Util.Alert(json.Msg);
						}
					});
				});
			},
			DeleteCase(){
				this.Util.Confirm("是否确定删除案件？",res=>{
					var data = {};
					data.Act="Delete_Case";
					data.ID=this.ID;
					data.DeleteType = 2;
					this.Util.Loading("请稍候...");
					this.Util.Post2(data, json=>{
						this.Util.HideLoading();
						if(json.State){
							this.Util.Toast(json.Msg, obj=>{
								this.Find_CaseInfo();
							});
						}else{
							this.Util.Alert(json.Msg);
						}
					});
				});
			}
		}
	}
</script>

<style lang="scss">
	.container{width:100%; padding-bottom:180rpx;
		.list{width:100%; height:80rpx; display:flex; flex-direction: row; padding-left:15rpx;  background-color: #ffffff; background-image: url('/static/arrow.png'); background-position: center right 10rpx; background-repeat: no-repeat; background-size: 36rpx;
			.icon{width:45rpx; height:45rpx; margin-top:18rpx; image{width:100%; height:100%;}}
			.name{flex:1; line-height: 80rpx; padding-left:10rpx; font-size:36rpx;}
			.dot{width:16rpx; height:16rpx; border-radius:10rpx; background-color:red; margin-right:60rpx; margin-top:32rpx;}
		}
		.list:active{background-color: #eae4e4;}
		.publishs{width:375rpx;}
		.deletes{flex:1; height:100rpx; line-height: 100rpx; background-color: #f41332; border:0rpx; border-radius: 0rpx; text-align: center; color:#ffffff; font-size:34rpx;}
	}
</style>
